using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using Dino;

namespace Tests.Dino.EntityFramework
{
    public class SomeEntity : ICollectionEntityRemoved
    {
        public SomeEntity()
        {
            SomeCollection = new ObservableCollection<Entity>();
            SomeCollection.CollectionChanged += CollectionChanged;
        }

        private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null)
            {
                foreach (var oldItem in e.OldItems)
                {
                    if (EntityRemoved != null)
                    {
                        EntityRemoved(oldItem);
                    }
                }
            }
        }

        public virtual ObservableCollection<Entity> SomeCollection { get; set; }

        public int Id { get; set; }
        public Entity Entity { get; set; }

        public event Action<object> EntityRemoved;
    }
}